{% extends 'layout.html' %}
{% load my_tags %}
{% block content %}

    <h4>应用列表</h4>

    <div class="row" style="margin-top: 20px; margin-bottom: 20px">
        <div class="col-md-7">
            {% if per.add %}
                <button style="margin-right: 60px" href="#" ser-oprate="1" class="btn btn-primary" id="add_serviceinfo">添加</button>
            {% endif %}

            {% if per.add %}
                <button style="margin-right: 60px" href="#"  class="btn btn-primary" id="copy_appinfo">复制</button>
            {% endif %}
        {% if per.add %}
                <button  href="#"  class="btn btn-primary" id="add_envinfo">添加组</button>
            {% endif %}
        </div><!-- /.col-lg-6 -->

        <div class="col-md-5">
            <form>
                <div class="input-group">
                <select type="text" class="form-control" name="group" id="current_group">
                        {% for gg in groups %}
                            {% if gg.0 == group %}
                                <option value="{{ gg.0 }}" selected="selected">{{ gg.1 }}</option>
                            {% else %}
                                <option value="{{ gg.0 }}">{{ gg.1 }}</option>
                            {% endif %}
                        {% endfor %}
                    </select>
                    <select type="text" class="form-control" name="env" id="current_env">
                        {% for ev in envs %}
                            {% if env == ev.0 %}
                                <option value="{{ ev.0 }}" selected="selected">{{ ev.1 }}</option>
                            {% else %}
                                <option value="{{ ev.0 }}">{{ ev.1 }}</option>
                            {% endif %}
                        {% endfor %}
                    </select>
                    {% if appname %}
                        <input type="text" class="form-control" name="appname" value="{{ appname }}">
                    {% else %}
                        <input type="text" id="current_app" class="form-control" name="appname" placeholder="模糊搜索应用名">
                    {% endif %}

                    <span class="input-group-btn">
                    <button class="btn btn-info" type="submit">搜索</button>
                  </span>
                </div><!-- /input-group -->
            </form>
        </div><!-- /.col-lg-6 -->
    </div><!-- /.row -->


    <div class="modal fade" id="url_info" tabindex="-1" role="dialog">
        <div class="modal-dialog  modal-mg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">添加应用信息</h4>
                    <button type="button" class="close" data-dismiss="modal" data-target="bs-example-modal-lg"
                            aria-label="Close"><span aria-hidden="true">&times;</span></button>
                </div>
                <div class="modal-body">
                    <form>
                        <div class="form-group" style="display: none">
                            <label for="proj_id" class="control-label">ID:</label>
                            <input type="text" class="form-control" id="proj_idddddd" readonly="readonly">
                        </div>
                        <div class="form-group">
                            <label for="app_type" class="control-label">应用类型:</label>
                            <div class="">
                                <select id="app_type" class="form-control">
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="proname" class="control-label">应用名称:</label>
                            <input type="text" class="form-control" id="proname" readonly="readonly" placeholder="应用名称">
                        </div>

                        <div class="form-group">
                            <label for="gitaddr" class="control-label">GIT地址:</label>
                            <input type="text" class="form-control" id="gitaddr" placeholder="GIT地址">
                        </div>
                        <div class="form-group">
                            <label for="comment">GIT分支(换行分割):</label>
                            <textarea class="form-control" id="git_release" rows="2" placeholder="GIT分支"></textarea>
                        </div>
                        <div class="form-group">
                            <label for="obj-num" class="control-label">部署实例数:</label>
                            <input type="text" class="form-control" id="obj-num" placeholder="默认是1" value="1">
                        </div>
                        <div class="form-group">
                            <label for="optimizationss" class="control-label">调优参数类型:</label>
                            <div class="">
                                <select id="optimizationss" class="form-control">
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="option_detail" class="control-label">调优参数详情:</label>
                            <input type="text" class="form-control" id="option_detail" placeholder="调优参数详情">
                        </div>
                        <div class="form-group">
                            <label for="system_version" class="control-label">操作系统:</label>
                            <div class="">
                                <select id="system_version" class="form-control">
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="java_version" class="control-label">Java版本:</label>
                            <div class="">
                                <select id="java_version" class="form-control">
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="cpu_capacity" class="control-label">CPU容量:</label>
                            <div class="">
                                <select id="cpu_capacity" class="form-control">
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="mem_capacity" class="control-label">内存容量(GB):</label>
                            <div class="">
                                <select id="mem_capacity" class="form-control">
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="configcenterss" class="control-label">配置类型:</label>
                            <div class="">
                                <select id="configcenterss" class="form-control">
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="configcenter_addr" class="control-label">配置-值:</label>
                            <input type="text" class="form-control" id="configcenter_addr" placeholder="配置中心地址">
                        </div>
                        <div class="form-group">
                            <label for="interface_typess" id="interface_typess"
                                   class="control-label">接口:</label>
                        </div>

                        <div class="form-group" style="margin-top: -20px;display: none" id="http-port-path">
                            <div class="form-group form-inline">
                                <label for="hostname" class="col-md-2 col-form-label">域名:</label>
                                <div class="col-md-10 p-0">
                                    <input type="text" class="form-control input-full" id="hostname"
                                           placeholder="域名">
                                </div>
                            </div>
                            <div class="form-group form-inline">
                                <label for="app-port" class="col-md-2 col-form-label">端口:</label>
                                <div class="col-md-4 p-0">
                                    <input type="text" class="form-control input-full" id="app-port"
                                           placeholder="端口">
                                </div>
                                <label for="app-path" class="col-md-2 col-form-label">路由:</label>
                                <div class="col-md-4 p-0">
                                    <input type="text" class="form-control input-full" id="app-path"
                                           placeholder="默认为(/)">
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="close_ip">关闭</button>
                    <button type="button" class="btn btn-primary" search-app="{{ search_app }}" id="add_save_app">保存
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <div class="modal fade" id="copy_info" tabindex="-1" role="dialog">
        <div class="modal-dialog  modal-mg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">复制至目标</h4>
                    <button type="button" class="close" data-dismiss="modal" data-target="bs-example-modal-lg"
                            aria-label="Close"><span aria-hidden="true">&times;</span></button>
                </div>
                <div class="modal-body">
                    <form>

                        <div class="form-group">
                            <label for="groupss" class="control-label">组名:</label>
                            <div class="">
                                <select id="groupss" class="form-control">
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="env_typeff" class="control-label">环境:</label>
                            <div class="">
                                <select id="env_typeff" class="form-control">
                                </select>
                            </div>
                        </div>

                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="close_ip">关闭</button>
                    <button type="button" class="btn btn-primary" search-app="{{ search_app }}" id="copy_save_app" data-dismiss="modal">保存
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <div class="modal fade" id="env_info" tabindex="-1" role="dialog">
        <div class="modal-dialog  modal-mg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">添加组信息</h4>
                    <button type="button" class="close" data-dismiss="modal" data-target="bs-example-modal-lg"
                            aria-label="Close"><span aria-hidden="true">&times;</span></button>
                </div>
                <div class="modal-body">
                    <form>
                        <div class="form-group">
                            <label for="env_name" class="control-label">组名:</label>
                            <input type="text" class="form-control" id="env_name"
                                   placeholder="组名">
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="close_ip">关闭</button>
                    <button type="button" class="btn btn-primary" search-app="{{ search_app }}" id="env_save_info" data-dismiss="modal">保存
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <div class="modal fade" id="edit_info" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
        <div class="modal-dialog  modal-mg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">修改项目信息</h4>
                    <button type="button" class="close" data-dismiss="modal" data-target="bs-example-modal-lg"
                            aria-label="Close"><span aria-hidden="true">&times;</span></button>
                </div>
                <div class="modal-body">
                    <form>
                        <div class="form-group" style="display: none">
                            <label for="proj_id" class="control-label">ID:</label>
                            <input type="text" class="form-control" id="proj_iddd" readonly="readonly">
                        </div>
                        <div class="form-group">
                            <label for="env_typesss" class="control-label">环境:</label>
                            <div class="">
                                <select id="env_typesss" class="form-control"></select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="app_types" class="control-label">应用类型:</label>
                            <div class="">
                                <select id="app_types" class="form-control">
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="pronames" class="control-label">应用名称:</label>
                            <input type="text" class="form-control" id="pronames" readonly="readonly"
                                   placeholder="应用名称">
                        </div>
                        <div class="form-group">
                            <label for="obj-nums" class="control-label">部署实例数:</label>
                            <input type="text" class="form-control" id="obj-nums" placeholder="默认是1">
                        </div>
                        <div class="form-group">
                            <label for="gitaddrs" class="control-label">GIT地址:</label>
                            <input type="text" class="form-control" id="gitaddrs" placeholder="GIT地址">
                        </div>
                        <div class="form-group">
                            <label for="comment">GIT分支(换行分割):</label>
                            <textarea class="form-control" id="git_releases" rows="2" placeholder="GIT分支"></textarea>
                        </div>

                        <div class="form-group">
                            <label for="optimizationsss" class="control-label">调优参数类型:</label>
                            <div class="">
                                <select id="optimizationsss" class="form-control">
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="option_details" class="control-label">调优参数详情:</label>
                            <input type="text" class="form-control" id="option_details" placeholder="调优参数详情">
                        </div>
                        <div class="form-group">
                            <label for="system_versionsss" class="control-label">操作系统:</label>
                            <div class="">
                                <select id="system_versionsss" class="form-control">
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="java_versions" class="control-label">Java版本:</label>
                            <div class="">
                                <select id="java_versions" class="form-control">
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="cpu_capacitys" class="control-label">CPU容量:</label>
                            <div class="">
                                <select id="cpu_capacitys" class="form-control">
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="mem_capacitys" class="control-label">内存容量(GB):</label>
                            <div class="">
                                <select id="mem_capacitys" class="form-control">
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="configcentersss" class="control-label">配置类型:</label>
                            <div class="">
                                <select id="configcentersss" class="form-control">
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="configcenter_addrs" class="control-label">配置-值:</label>
                            <input type="text" class="form-control" id="configcenter_addrs" placeholder="配置-值">
                        </div>
                        <div class="form-group">
                            <label for="interface_typesss" id="interface_typesss"
                                   class="control-label">接口:</label>
                        </div>
                        <div class="form-group" style="margin-top: -20px;display: none" id="http-port-paths">
                            <div class="form-group form-inline">
                                <label for="hostnames" class="col-md-2 col-form-label">域名:</label>
                                <div class="col-md-10 p-0">
                                    <input type="text" class="form-control input-full" id="hostnames"
                                           placeholder="域名">
                                </div>
                            </div>
                            <div class="form-group form-inline">
                                <label for="app-ports" class="col-md-2 col-form-label">端口:</label>
                                <div class="col-md-4 p-0">
                                    <input type="text" class="form-control input-full" id="app-ports"
                                           placeholder="端口">
                                </div>
                                <label for="app-paths" class="col-md-2 col-form-label">路由:</label>
                                <div class="col-md-4 p-0">
                                    <input type="text" class="form-control input-full" id="app-paths"
                                           placeholder="默认为(/)">
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="close_ip">关闭</button>
                    <button type="button" class="btn btn-primary" search-app="{{ search_app }}" data-dismiss="modal"
                            id="edit_save_app">保存
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <table class="table table-bordered table-striped">
        <thead>
        <tr>
            <th>选择</th>
            <th>应用名称</th>
            <th>代码仓库地址</th>
            <th>组</th>
            <th>环境</th>
            <th>JOB</th>
            <th>导航</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {% for service in server_list %}
            <tr>

                <td><label class="form-check-label">
                    <input class="form-check-input" type="checkbox" data-appss-id="{{ service.id }}" data-app-idss="application-app" value="" >
                    <span class="form-check-sign"></span>
                </label></td>
                <td>{{ service.sername.sername }}</td>
                <td>{{ service.sername.gitaddr }}</td>
                <td>{{ service.group.name }}</td>
                <td>{{ service.get_env_type_display }}</td>
                <td data-td-id="{{ service.id }}">
                    {% if service.jenkens_status == 3 %}
                        <button data-btn-id="{{ service.id }}"
                                class="btn btn-default estiblish">{{ service.get_jenkens_status_display }}</button>
                    {% elif service.jenkens_status == 2 %}
                        <button data-btn-id="{{ service.id }}"
                                class="btn btn-warning">{{ service.get_jenkens_status_display }}</button>
                    {% else %}
                        <button data-btn-id="{{ service.id }}"
                                class="btn btn-success">{{ service.get_jenkens_status_display }}</button>
                    {% endif %}
                </td>
                <td><a href="http://10.37.253.238:8080/job/{% jenkins_list service.sername.sername service.get_env_type_display service.group.name %}/"><button class="btn btn-success">Jenkins</button></a> </td>
                <td>
                    {% if per.edit %}
                        <a href="#" class="btn btn-warning editproj" data-proj-id="{{ service.id }}"
                           data-env-id="{{ service.env_type }}">编辑</a>
                    {% endif %}
                    {% if per.delete %}
                        <a href="#" class="btn btn-danger deleteproj" data-proj-id="{{ service.id }}"
                           data-proj-name="{{ service.sername.sername }}">删除</a>
                    {% endif %}
                </td>
            </tr>
        {% endfor %}

        </tbody>
    </table>
    <ul class="pagination pg-primary pull-right">
        {{ page_html|safe }}
    </ul>

{% endblock %}

{% block jss %}
    <script src="/static/serviceinfo/connservicelist.js"></script>
{% endblock %}